package com.gaoxin.api.service.common;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gaoxin.api.dao.common.LoginMapper;
import com.gaoxin.api.entity.statisentity.StudentInfo;
import com.gaoxin.api.entity.statisentity.User;
/**
 * 登录Service
 * @author zhaozhenshe
 *2018-07-16
 */
@Service
public class LoginService {
	@Autowired
	private LoginMapper loginMapper;
	/**
	 * 判断登录
	 * @param user
	 * @return
	 */
	public User login(String userCode, String password)throws Exception{
		User user = new User();
		user.setUserCode(userCode);
		user.setPassword(password);
		return loginMapper.login(user);
	}
	/**
	 * 查询用户名是否存在
	 * @param userCode
	 * @return
	 */
	public User queryUserCode(String userCode){
		return loginMapper.queryUserCode(userCode);
	}
	/**
	 * 根据学生手机号查询学生信息
	 * @param mobile
	 * @return
	 */
	public StudentInfo queryStuNumber(String phone)throws Exception{
		return loginMapper.queryStuNumber(phone);
	}
	/**
	 * 根据用户手机号查询用户信息
	 * @param mobile
	 * @return
	 */
	public User queryUserInfo(String mobile)throws Exception{
		return loginMapper.queryUserInfo(mobile);
	}
	/**
	  * 查询用户账号
	  * @param mobile
	  * @return
	  */
	 public User queryUserId(String idCard)throws Exception{
	  return loginMapper.queryUserId(idCard);
	 }
	 /**
	  * 查询所有的员工和学生
	  * @param mobile
	  * @return
	  * @throws Exception
	  */
	 public List<User> queryAllUser()throws Exception{
		  return loginMapper.queryAllUser();
	}
}
